﻿#ifndef ANDYRP_SHADOW_INCLUDED
#define ANDYRP_SHDAOW_INCLUDED

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl"

CBUFFER_START(_ShadowBuffer)
    float4x4 _WorldToShadowMatrix;
    float _ShadowStrength;
    float4 _ShadowMapSize;
CBUFFER_END

TEXTURE2D_SHADOW(_ShadowMap);
SAMPLER_CMP(sampler_ShadowMap);

float ShadowAttenuation(float3 worldPos)
{
    float4 shadowPos = mul(_WorldToShadowMatrix, float4(worldPos, 1.0));
    shadowPos.xyz /= shadowPos.w;
    float shadowAtten =  SAMPLE_TEXTURE2D_SHADOW(_ShadowMap, sampler_ShadowMap, shadowPos.xyz);
    return lerp(1, shadowAtten, _ShadowStrength);
}


#endif